/*
 * @(#)UserData.java   09/12/30
 * 
 * Copyright (C) 2009 Ecole des Mines d'Ales
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact: yulinz88@gmail.com
 */



package Example.Components;

import Example.Interfaces.UQuery;
import Example.Interfaces.USave;

import java.util.Vector;

//~--- classes ----------------------------------------------------------------

/**
 * Class description
 *
 *
 * @version        1.0, 09/12/30
 * @author         Huaxi (Yulin) ZHANG    
 */
public class UserData implements UQuery, USave {

    /** Field description */
    Vector users = new Vector();

    /**
     * Constructs ...
     *
     */
    public UserData() {
        Object[] u1 = {
            Integer.valueOf(001), "user1", "yulin1", "ZHANG1", "Triolet,montpellier", Double.valueOf(10)
        };
        Object[] u2 = {
            Integer.valueOf(002), "user2", "yulin2", "ZHANG2", "Gare,montpellier", Double.valueOf(10)
        };
        Object[] u3 = {
            Integer.valueOf(003), "user3", "yulin3", "ZHANG3", "Polygone,montpellier", Double.valueOf(10)
        };

        users.add(u1);
        users.add(u2);
        users.add(u3);
    }

    /**
     * Method description
     *
     * @param userID  
     * @param userPassword  
     * @return  
     */
    public Object[] findAccount(int userID, String userPassword) {
        Object[] userF = null;

        for (int i = 0; i < users.size(); i++) {
            Object[] a = (Object[]) users.get(i);

            if ((a[0] == Integer.valueOf(userID)) && a[1].equals(userPassword)) {
                userF = a;

                return userF;
            }
        }

        return null;
    }

    /**
     * Method description
     *
     * @param userID  
     * @param cost  
     * @return  
     */
    public double storeAccount(int userID, double cost) {

        // TODO Auto-generated method stub
        return 0;
    }
}
